package com.sf.fy.uav.applet.config;

import com.sf.fy.uav.applet.popscreen.PopScreenScheduleTask;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ta136817
 */
@Configuration
public class QuartzConfig {
    @Bean
    public JobDetail cancelOrderJobDetail() {
        //PrintTimeJob我们的业务类
        return JobBuilder.newJob(PopScreenScheduleTask.class)
                //可以给该JobDetail起一个id
                .withIdentity("cancelOrderJob")
                //即使没有Trigger关联时，也不需要删除该JobDetail
                .storeDurably()
                .build();
    }

    @Bean
    public Trigger cancelOrderJobTrigger() {
        CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule("30 * * * * ?");
        return TriggerBuilder.newTrigger()
                //关联上述的JobDetail
                .forJob(cancelOrderJobDetail())
                //给Trigger起个名字
                .withIdentity("cancelOrderTrigger")
                .withSchedule(cronScheduleBuilder)
                .build();
    }

}
